<!--
 * @Descripttion: 
 * @version: 
 * @Author: Peanut
 * @Date: 2024-04-20 11:30:02
 * @LastEditors: Peanut
 * @LastEditTime: 2024-04-28 11:36:08
-->
<template>
  <div class="headerArea">
    <div class="title">茶叶嫩芽检测系统</div>
    <div class="content">
      <i class="el-icon-paperclip" style="margin-right: 10px"></i>
      <span>{{ userType == "user" ? "用户" : "管理员" }}</span>

      <el-divider direction="vertical"></el-divider>

      <i class="el-icon-user" style="margin-right: 10px"></i>
      <span>{{ name }}</span>

      <el-divider direction="vertical" style="color: #333333"></el-divider>

      <div
        class="logoutBox"
        type="text"
        style="color: #333333; font-size: 18px"
        @click="out()"
      >
        退出登录
        <img src="@/assets/imgs/logout2.png" alt="" />
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "r-header",
  data() {
    return {
      name: null,
      userType: null,
    };
  },
  created() {
    // this.name = sessionStorage.getItem("name");
    // this.userType = sessionStorage.getItem("userType");
    this.name = JSON.parse(sessionStorage.getItem("userData")).name;
    this.userType = JSON.parse(sessionStorage.getItem("userData")).role;
  },
  methods: {
    out() {
      sessionStorage.clear();
      this.$router.push("/");
    },
  },
};
</script>

<style lang="scss" scoped>
.headerArea {
  width: 100%;
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .title {
    background: linear-gradient(
      to bottom,
      rgb(107, 240, 138),
      rgb(245, 137, 209)
    );
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: bold;
    font-size: 30px;
  }
  .content {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 30%;
  }
  .logoutBox {
    display: flex;
    align-items: center;
    cursor: pointer;
    img {
      margin-left: 10px;
      width: 20px;
      height: 20px;
    }
  }
}
</style>
